﻿using GENERIC.DBProvider;
using System;
using System.Collections.Generic;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Text;

namespace GENERIC.EFRepository
{
    public static class ConnectionFactories
    {

        public static IDbConnectionFactory GetConnectionFactory(eConnectionType type, string connectionString)
        {
            switch (type)
            {
                case eConnectionType.SQLServer:
                    return new SqlConnectionFactory(connectionString);
                case eConnectionType.SqlCE:
                    return new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0", "", connectionString);
                default:
                    throw new NotImplementedException();
            }
        }

        public static IDbConnectionFactory GetConnectionFactory(string providerName, string connectionString)
        {
            switch (providerName)
            {
                case "System.Data.SqlClient":
                    return new SqlConnectionFactory(connectionString);
                case "System.Data.SqlServerCe":
                    return new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0", "", connectionString);
                default:
                    throw new NotImplementedException();
            }
        }
    }
}
